use ndarray::array;
use rstest::rstest;

use super::super::*;
use crate::tests::fixtures::{
    neighbor_association_tile_list,
    rand_bool,
    rand_usize,
    random_last_leaves,
    random_missing_tile_policy,
    random_predecessor,
    random_tile_selection_policy,
    RANDOM_USIZE,
};
use crate::tiling::slot_grid::tests::{
    create_grid_slot_or_none,
    create_grid_slot_with_some_tile_id,
    pad_coordinates_randomly,
    pad_grid_randomly,
};

// There are identical arrays used in the following cases. Hard-coding and
// repetition is fine in test data, so
// noinspection DuplicatedCode
#[rstest]
#[rustfmt::skip]
// region Ignore policy
#[case::ignore_policy(
    pad_coordinates_randomly((rand_usize(1, 5), rand_usize(1, 5))),
    // ╭─────────╮
    // │ ? ? ? ? │
    // │ ? ? ? ? │
    // │ ? ? ? ? │
    // │ ? ? ? ? │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None,None, None],
        [
            None,
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
        ],
        [
            None,
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
        ],
        [
            None,
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
        ],
        [
            None,
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
            create_grid_slot_or_none(),
        ],
    ]),
    VacancyPolicy::Ignore,
    rand_usize(0, 10),
    vec![],
)]
// endregion
// region Avoid policy, NESW, no exposed edges present, one neighbor association
#[case::avoid_policy_nesw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, NESW, no exposed edges present, one neighbor association, occupied
#[case::avoid_policy_nesw_no_exposed_edges_present_one_neighbor_association_occupied(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │   1   │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(1), None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, NESW, no exposed edges present, one neighbor association, ne alt.
#[case::avoid_policy_nesw_no_exposed_edges_present_one_neighbor_association_ne_alt(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │     0 │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, NESW, no exposed edges present, one neighbor association, sw alt.
#[case::avoid_policy_nesw_no_exposed_edges_present_one_neighbor_association_sw_alt(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0     │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, NESW, no exposed edges present, one neighbor association, large
#[case::avoid_policy_nesw_no_exposed_edges_present_one_neighbor_association_large(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │         │
    // │         │
    // │         │
    // │         │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, NEW, S, no exposed edges present, two neighbor associations
#[case::avoid_policy_new_s_no_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │ 0   0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![
        HashSet::from([Direction::North, Direction::East, Direction::West]),
        HashSet::from([Direction::South])
    ],
)]
// endregion
// region Avoid policy, NES, no exposed edges present, one neighbor association
#[case::avoid_policy_nes_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │ 0     │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South])],
)]
// endregion
// region Avoid policy, NEW, no exposed edges present, one neighbor association
#[case::avoid_policy_new_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │   0   │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(0), None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::West])],
)]
// endregion
// region Avoid policy, NSW, no exposed edges present, one neighbor association
#[case::avoid_policy_nsw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │     0 │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, ESW, no exposed edges present, one neighbor association
#[case::avoid_policy_esw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │   0   │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(0), None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, NEW, exposed edges present, no neighbor associations
#[case::avoid_policy_new_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │   5   │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(5), None],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, NSW, exposed edges present, no neighbor associations
#[case::avoid_policy_nsw_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │     1 │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(1)],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, ESW, exposed edges present, no neighbor associations
#[case::avoid_policy_esw_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │   4   │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(4), None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, ESW, exposed edges present, no neighbor associations, large
#[case::avoid_policy_esw_exposed_edges_present_no_neighbor_associations_large(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │     2   │
    // │         │
    // │         │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(2), None],
        [None, None, None, None, None],
        [None, None, None, None, None],
        [None, None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, ES, W, no exposed edges present, two neighbor associations
#[case::avoid_policy_es_w_no_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │ 0 0 0   │
    // │ 0       │
    // │ 0 0     │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
        ],
        [None, None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East, Direction::South]), HashSet::from([Direction::West])],
)]
// endregion
// region Avoid policy, ES, W, exposed edges present, two neighbor associations
#[case::avoid_policy_es_w_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │ 0 0 0   │
    // │ 0       │
    // │ 0 2     │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(2),
            None,
            None,
        ],
        [None, None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::East, Direction::South]), HashSet::from([Direction::West])],
)]
// endregion
// region Avoid policy, N, E, S, no exposed edges present, three neighbor associations
#[case::avoid_policy_n_e_s_no_exposed_edges_present_three_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │   0 0 0 │
    // │ 0 0   0 │
    // │ 0 0     │
    // │ 0 0   0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![
        HashSet::from([Direction::North]),
        HashSet::from([Direction::East]),
        HashSet::from([Direction::South]),
    ],
)]
// endregion
// region Avoid policy, N, E, W, no exposed edges present, three neighbor associations
#[case::avoid_policy_n_e_w_no_exposed_edges_present_three_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │   0 0 0 │
    // │ 0 0   0 │
    // │ 0       │
    // │ 0 0 0 0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![
        HashSet::from([Direction::North]),
        HashSet::from([Direction::East]),
        HashSet::from([Direction::West]),
    ],
)]
// endregion
// region Avoid policy, E, S, W, no exposed edges present, three neighbor associations
#[case::avoid_policy_e_s_w_no_exposed_edges_present_three_neighbor_associations(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │ 0 0 0   │
    // │ 0       │
    // │ 0 0   0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![
        HashSet::from([Direction::East]),
        HashSet::from([Direction::South]),
        HashSet::from([Direction::West]),
    ],
)]
// endregion
// region Avoid policy, N, E, S, exposed edges present, three neighbor associations
#[case::avoid_policy_n_e_s_exposed_edges_present_three_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │   0 0 0 │
    // │ 0 0   3 │
    // │ 0 0     │
    // │ 0 0   0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(3),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![
        HashSet::from([Direction::North]),
        HashSet::from([Direction::East]),
        HashSet::from([Direction::South]),
    ],
)]
// endregion
// region Avoid policy, NE, no exposed edges present, one neighbor association
#[case::avoid_policy_ne_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0     0 │
    // │ 0     0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::East])],
)]
// endregion
// region Avoid policy, NE, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_ne_no_exposed_edges_present_one_neighbor_association_corner(
    (3 + *RANDOM_USIZE * 3, 1),
    // ╭───────╮
    // │       │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East, Direction::North])],
)]
// endregion
// region Avoid policy, NW, no exposed edges present, one neighbor association
#[case::avoid_policy_nw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │       0 │
    // │     0 0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::West])],
)]
// endregion
// region Avoid policy, NW, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_nw_no_exposed_edges_present_one_neighbor_association_corner(
    (3 + *RANDOM_USIZE * 3, 3 + *RANDOM_USIZE * 4),
    // ╭───────╮
    // │       │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North, Direction::West])],
)]
// endregion
// region Avoid policy, ES, no exposed edges present, one neighbor association
#[case::avoid_policy_es_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0 0   0 │
    // │ 0     0 │
    // │ 0     0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East, Direction::South])],
)]
// endregion
// region Avoid policy, ES, no exposed edges present, one neighbor association, altern.
#[case::avoid_policy_es_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0 0   0 │
    // │ 0     0 │
    // │       0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East, Direction::South])],
)]
// endregion
// region Avoid policy, ES, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_es_no_exposed_edges_present_one_neighbor_association_corner(
    (1, 1),
    // ╭───────╮
    // │       │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East, Direction::South])],
)]
// endregion
// region Avoid policy, SW, no exposed edges present, one neighbor association
#[case::avoid_policy_sw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0 0   0 │
    // │     0 0 │
    // │       0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, SW, no exposed edges present, one neighbor association, altern.
#[case::avoid_policy_sw_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │   0   0 │
    // │     0 0 │
    // │       0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, SW, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_sw_no_exposed_edges_present_one_neighbor_association_corner(
    (1, 3 + *RANDOM_USIZE * 4),
    // ╭───────╮
    // │       │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::South, Direction::West])],
)]
// endregion
// region Avoid policy, NE, exposed edges present, no neighbor associations
#[case::avoid_policy_ne_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0     0 │
    // │ 0     0 │
    // │ 0 0 0 0 │
    // │     2   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(2),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, N, E, no exposed edges present, two neighbor associations
#[case::avoid_policy_n_e_no_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0   0 0 │
    // │ 0     0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North]), HashSet::from([Direction::East])],
)]
// endregion
// region Avoid policy, N, E, exposed edges present, two neighbor associations
#[case::avoid_policy_n_e_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     4 0 │
    // │ 0   0 0 │
    // │ 0     0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(4),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::North]), HashSet::from([Direction::East])],
)]
// endregion
// region Avoid policy, S, W, exposed edges present, two neighbor associations
#[case::avoid_policy_s_w_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     4 0 │
    // │ 0 0 0 0 │
    // │     0 0 │
    // │ 0   0 0 │
    // │ 0 0 0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(4),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::South]), HashSet::from([Direction::West])],
)]
// endregion
// region Avoid policy, N, S, exposed edges present, two neighbor associations
#[case::avoid_policy_n_s_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     4 0 │
    // │ 0   0 0 │
    // │ 0   0 0 │
    // │ 0   0 0 │
    // │ 0 0 0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(4),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::North]), HashSet::from([Direction::South])],
)]
// endregion
// region Avoid policy, N, no exposed edges present, one neighbor association
#[case::avoid_policy_n_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │ 0   0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North])],
)]
// endregion
// region Avoid policy, N, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_n_no_exposed_edges_present_one_neighbor_association_corner(
    (3, 1),
    // ╭───────╮
    // │       │
    // │       │
    // │   0   │
    // ╰───────╯
    array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(0), None],
    ],
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North])],
)]
// endregion
// region Avoid policy, N, no exposed edges present, one neighbor association, corner, altern.
#[case::avoid_policy_n_no_exposed_edges_present_one_neighbor_association_corner_altern(
    (4, 1),
    // ╭───────╮
    // │       │
    // │       │
    // │       │
    // │   0   │
    // ╰───────╯
    array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(0), None],
    ],
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::North])],
)]
// endregion
// region Avoid policy, E, no exposed edges present, one neighbor association
#[case::avoid_policy_e_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0   │
    // │ 0     │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(0), None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East])],
)]
// endregion
// region Avoid policy, E, no exposed edges present, one neighbor association, altern.
#[case::avoid_policy_e_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0   │
    // │ 0     │
    // │ 0 0   │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(0), None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(0), None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East])],
)]
// endregion
// region Avoid policy, E, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_e_no_exposed_edges_present_one_neighbor_association_corner(
    (2, 1),
    // ╭───────╮
    // │ 0     │
    // │       │
    // │ 0     │
    // ╰───────╯
    array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
    ],
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::East])],
)]
// endregion
// region Avoid policy, S, no exposed edges present, one neighbor association
#[case::avoid_policy_s_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │ 0   0 │
    // │ 0   0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::South])],
)]
// endregion
// region Avoid policy, S, no exposed edges present, one neighbor association, altern
#[case::avoid_policy_s_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │ 0   0 │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, None],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::South])],
)]
// endregion
// region Avoid policy, S, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_s_no_exposed_edges_present_one_neighbor_association_corner(
    (1, 2),
    // ╭───────╮
    // │ 0   0 │
    // │       │
    // │ 0     │
    // ╰───────╯
    array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
    ],
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::South])],
)]
// endregion
// region Avoid policy, W, no exposed edges present, one neighbor association
#[case::avoid_policy_w_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │     0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0)
        ],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::West])],
)]
// endregion
// region Avoid policy, W, no exposed edges present, one neighbor association, corner
#[case::avoid_policy_w_no_exposed_edges_present_one_neighbor_association_corner(
    (3, 3),
    // ╭───────╮
    // │ 0   0 │
    // │     0 │
    // │ 0     │
    // ╰───────╯
    array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
    ],
    VacancyPolicy::Avoid,
    0,
    vec![HashSet::from([Direction::West])],
)]
// endregion
// region Avoid policy, N, exposed edges present, no neighbor associations
#[case::avoid_policy_n_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │ 1   0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(1), None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, E, exposed edges present, no neighbor associations
#[case::avoid_policy_e_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 2   │
    // │ 0     │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(2), None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, S, exposed edges present, no neighbor associations
#[case::avoid_policy_s_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │ 0   0 │
    // │ 2   0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, create_grid_slot_with_some_tile_id(2), None, create_grid_slot_with_some_tile_id(0)],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region Avoid policy, W, exposed edges present, no neighbor associations
#[case::avoid_policy_w_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 3 0 0 │
    // │     0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(3),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0)
        ],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::Avoid,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, NESW, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_nesw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NESW, no exposed edges present, one neighbor association, occupied
#[case::avoid_strict_policy_nesw_no_exposed_edges_present_one_neighbor_association_occupied(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │   1   │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(1), None],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NESW, no exposed edges present, one neighbor association, ne alt.
#[case::avoid_strict_policy_nesw_no_exposed_edges_present_one_neighbor_association_ne_alt(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │     0 │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NESW, no exposed edges present, one neighbor association, sw alt.
#[case::avoid_strict_policy_nesw_no_exposed_edges_present_one_neighbor_association_sw_alt(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0     │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NESW, no exposed edges present, one neighbor association, large
#[case::avoid_strict_policy_nesw_no_exposed_edges_present_one_neighbor_association_large(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │         │
    // │         │
    // │         │
    // │         │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
        [None, None, None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NEW, S, no exposed edges present, two neighbor associations
#[case::avoid_strict_policy_new_s_no_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │ 0   0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),

        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![
        HashSet::from([Direction::North, Direction::East, Direction::West]),
        HashSet::from([Direction::South])
    ],
)]
// endregion
// region AvoidStrict policy, NES, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_nes_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │ 0     │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::South])],
)]
// endregion
// region AvoidStrict policy, NEW, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_new_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │   0   │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(0), None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NSW, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_nsw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │     0 │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, ESW, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_esw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │   0   │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(0), None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::East, Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NEW, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_new_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │       │
    // │   5   │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(5), None],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, NSW, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_nsw_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │     1 │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(1)],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, ESW, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_esw_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │   4   │
    // │       │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, create_grid_slot_with_some_tile_id(4), None],
        [None, None, None, None],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, ESW, exposed edges present, no neighbor associations, large
#[case::avoid_strict_policy_esw_exposed_edges_present_no_neighbor_associations_large(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │     2   │
    // │         │
    // │         │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [None, None, None, create_grid_slot_with_some_tile_id(2), None],
        [None, None, None, None, None],
        [None, None, None, None, None],
        [None, None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, ES, W, no exposed edges present, two neighbor associations
#[case::avoid_strict_policy_es_w_no_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │ 0 0 0   │
    // │ 0       │
    // │ 0 0     │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
        ],
        [None, None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::West]), HashSet::from([Direction::East, Direction::South])],
)]
// endregion
// region AvoidStrict policy, ES, W, exposed edges present, one neighbor association
#[case::avoid_strict_policy_es_w_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │ 0 0 0   │
    // │ 0       │
    // │ 0 ₂     │
    // │         │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(rand_usize(2, 4)),
            None,
            None,
        ],
        [None, None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::West])],
)]
// endregion
// region AvoidStrict policy, N, E, S, no exposed edges present, three neighbor associations
#[case::avoid_strict_policy_n_e_s_no_exposed_edges_present_three_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │   0 0 0 │
    // │ 0 0   0 │
    // │ 0 0     │
    // │ 0 0   0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![
        HashSet::from([Direction::South]),
        HashSet::from([Direction::East]),
        HashSet::from([Direction::North]),
    ],
)]
// endregion
// region AvoidStrict policy, N, E, W, no exposed edges present, three neighbor associations
#[case::avoid_strict_policy_n_e_w_no_exposed_edges_present_three_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │   0 0 0 │
    // │ 0 0   0 │
    // │ 0       │
    // │ 0 0 0 0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            None,
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![
        HashSet::from([Direction::West]),
        HashSet::from([Direction::East]),
        HashSet::from([Direction::North]),
    ],
)]
// endregion
// region AvoidStrict policy, E, S, W, no exposed edges present, three neighbor associations
#[case::avoid_strict_policy_e_s_w_no_exposed_edges_present_three_neighbor_associations(
    pad_coordinates_randomly((2, 3)),
    // ╭─────────╮
    // │ 0 0 0   │
    // │ 0       │
    // │ 0 0   0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![
        HashSet::from([Direction::West]),
        HashSet::from([Direction::South]),
        HashSet::from([Direction::East]),
    ],
)]
// endregion
// region AvoidStrict policy, N, E, S, exposed edges present, two neighbor associations
#[case::avoid_strict_policy_n_e_s_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭─────────╮
    // │   0 0 0 │
    // │ 0 0   3 │
    // │ 0 0     │
    // │ 0 0   0 │
    // │   0 0 0 │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(3),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![
        HashSet::from([Direction::South]),
        HashSet::from([Direction::North]),
    ],
)]
// endregion
// region AvoidStrict policy, NE, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_ne_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0     0 │
    // │ 0     0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::East])],
)]
// endregion
// region AvoidStrict policy, NW, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_nw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │       0 │
    // │     0 0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North, Direction::West])],
)]
// endregion
// region AvoidStrict policy, ES, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_es_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0 0   0 │
    // │ 0     0 │
    // │ 0     0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::East, Direction::South])],
)]
// endregion
// region AvoidStrict policy, ES, no exposed edges present, one neighbor association, altern.
#[case::avoid_strict_policy_es_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0 0   0 │
    // │ 0     0 │
    // │       0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::East, Direction::South])],
)]
// endregion
// region AvoidStrict policy, SW, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_sw_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0 0   0 │
    // │     0 0 │
    // │       0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, SW, no exposed edges present, one neighbor association, altern.
#[case::avoid_strict_policy_sw_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │   0   0 │
    // │     0 0 │
    // │       0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::South, Direction::West])],
)]
// endregion
// region AvoidStrict policy, NE, exposed edges present, one neighbor association
#[case::avoid_strict_policy_ne_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((4, 3)),
    // ╭───────────╮
    // │ 0 0 0 0 0 │
    // │ 0     0 0 │
    // │   0     0 │
    // │   0     0 │
    // │   0 0 0 0 │
    // │       2 0 │
    // ╰───────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(2),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::North, Direction::East])],
)]
// endregion
// region AvoidStrict policy, NE, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_ne_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭───────────╮
    // │       0 0 │
    // │   0     0 │
    // │   0     0 │
    // │   0 0 0 0 │
    // │       2   │
    // │           │
    // ╰───────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None, None],
        [
            None,
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(2),
            None,
        ],
        [
            None,
            None,
            None,
            None,
            None,
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, N, E, no exposed edges present, two neighbor associations
#[case::avoid_strict_policy_n_e_no_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     0 0 │
    // │ 0   0 0 │
    // │ 0     0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::East]), HashSet::from([Direction::North])],
)]
// endregion
// region AvoidStrict policy, N, E, exposed edges present, one neighbor association
#[case::avoid_strict_policy_n_e_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     4 0 │
    // │ 0   0 0 │
    // │ 0     0 │
    // │ 0 0 0 0 │
    // │     0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(4),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::East])],
)]
// endregion
// region AvoidStrict policy, S, W, exposed edges present, two neighbor associations
#[case::avoid_strict_policy_s_w_exposed_edges_present_two_neighbor_associations(
    pad_coordinates_randomly((3, 3)),
    // ╭───────────╮
    // │       4 0 │
    // │   0 0 0 0 │
    // │ 0     0 0 │
    // │   0   0 0 │
    // │   0 0 0   │
    // ╰───────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None, None],
        [
            None,
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(4),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::West]), HashSet::from([Direction::South])],
)]
// endregion
// region AvoidStrict policy, N, S, exposed edges present, one neighbor association
#[case::avoid_strict_policy_n_s_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((3, 2)),
    // ╭─────────╮
    // │     4 0 │
    // │ 0   0 0 │
    // │ 0   0 0 │
    // │ 0   0 0 │
    // │ 0 0 0   │
    // ╰─────────╯
    pad_grid_randomly(array![
        [None, None, None, None, None],
        [
            None,
            None,
            None,
            create_grid_slot_with_some_tile_id(4),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            None,
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![HashSet::from([Direction::South])],
)]
// endregion
// region AvoidStrict policy, N, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_n_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │ 0   0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::North])],
)]
// endregion
// region AvoidStrict policy, E, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_e_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0   │
    // │ 0     │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(0), None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::East])],
)]
// endregion
// region AvoidStrict policy, E, no exposed edges present, one neighbor association, altern.
#[case::avoid_strict_policy_e_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0   │
    // │ 0     │
    // │ 0 0   │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(0), None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(0), None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::East])],
)]
// endregion
// region AvoidStrict policy, S, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_s_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │ 0   0 │
    // │ 0   0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::South])],
)]
// endregion
// region AvoidStrict policy, S, no exposed edges present, one neighbor association, altern
#[case::avoid_strict_policy_s_no_exposed_edges_present_one_neighbor_association_altern(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │ 0   0 │
    // │       │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, None, None, None],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::South])],
)]
// endregion
// region AvoidStrict policy, W, no exposed edges present, one neighbor association
#[case::avoid_strict_policy_w_no_exposed_edges_present_one_neighbor_association(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │     0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0)
        ],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    0,
    vec![HashSet::from([Direction::West])],
)]
// endregion
// region AvoidStrict policy, N, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_n_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │       │
    // │ 1   0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(1), None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, E, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_e_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 2   │
    // │ 0     │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [None, create_grid_slot_with_some_tile_id(0), create_grid_slot_with_some_tile_id(2), None],
        [None, create_grid_slot_with_some_tile_id(0), None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, S, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_s_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 0 0 0 │
    // │ 0   0 │
    // │ 2   0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
        [None, create_grid_slot_with_some_tile_id(0), None, create_grid_slot_with_some_tile_id(0)],
        [None, create_grid_slot_with_some_tile_id(2), None, create_grid_slot_with_some_tile_id(0)],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
// region AvoidStrict policy, W, exposed edges present, no neighbor associations
#[case::avoid_strict_policy_w_exposed_edges_present_no_neighbor_associations(
    pad_coordinates_randomly((2, 2)),
    // ╭───────╮
    // │ 3 0 0 │
    // │     0 │
    // │ 0 0 0 │
    // ╰───────╯
    pad_grid_randomly(array![
        [None, None, None, None],
        [
            None,
            create_grid_slot_with_some_tile_id(3),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0)
        ],
        [None, None, None, create_grid_slot_with_some_tile_id(0)],
        [
            None,
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
            create_grid_slot_with_some_tile_id(0),
        ],
    ]),
    VacancyPolicy::AvoidStrict,
    rand_usize(1, 10),
    vec![],
)]
// endregion
fn test_slot_grid_determine_neighbor_associations(
    #[case] current_slot: (usize, usize),
    #[case] grid: Array2<Option<GridSlot>>,
    #[case] vacancy_policy: VacancyPolicy,
    #[case] exposed_edge_count: usize,
    #[case] expected_result: Vec<HashSet<Direction>>,
) {
    let tile_list = neighbor_association_tile_list();
    let slot_grid = SlotGrid {
        num_rows: grid.nrows() - 1,
        num_cols: grid.ncols() - 1,
        grid,
        border_tile_id: if rand_bool() {
            None
        } else {
            Some(rand_usize(0, 9))
        },
        tile_connections: TileConnectionArray::new(&tile_list.tiles),
        tile_list,
        missing_tile_policy: random_missing_tile_policy(),
        tile_selection_policy: random_tile_selection_policy(),
        vacancy_policy,
        current_slot,
        current_predecessor: random_predecessor(),
        last_leaves: random_last_leaves(),
        exposed_edge_count,
    };

    let result = slot_grid.determine_neighbor_associations();

    assert_eq!(result, expected_result);
    // Access slot_grid to ensure it was not moved.
    drop(slot_grid);
}
